package com.tuangou.tuangouorder.order.controller;

import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;
import com.tuangou.tuangouorder.order.entity.TuanzhangEntity;
import com.tuangou.tuangouorder.order.service.TuanzhangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 
 *
 * @author lsy
 * @email lsy@tuangou.com
 * @date 2021-06-18 20:36:33
 */
@RestController
@RequestMapping("order/tuanzhang")
public class TuanzhangController {
    @Autowired
    private TuanzhangService tuanzhangService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("order:tuanzhang:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tuanzhangService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{tzId}")
    //@RequiresPermissions("order:tuanzhang:info")
    public R info(@PathVariable("tzId") Integer tzId){
		TuanzhangEntity tuanzhang = tuanzhangService.getById(tzId);

        return R.ok().put("tuanzhang", tuanzhang);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("order:tuanzhang:save")
    public R save(@RequestBody TuanzhangEntity tuanzhang){
		tuanzhangService.save(tuanzhang);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("order:tuanzhang:update")
    public R update(@RequestBody TuanzhangEntity tuanzhang){
		tuanzhangService.updateById(tuanzhang);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("order:tuanzhang:delete")
    public R delete(@RequestBody Integer[] tzIds){
		tuanzhangService.removeByIds(Arrays.asList(tzIds));

        return R.ok();
    }

}
